package app.view.component
{
	import mx.collections.ArrayCollection;
	import mx.controls.ComboBox;
	import mx.events.FlexEvent;

	public class StateComboBox extends ComboBox
	{
		private static var sharedData:ArrayCollection;
		
		public function StateComboBox()		{
			addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
		}
	    
	    public function set sharedDataProvider( a:Object):void{
	    	if(a is Array){
	    		sharedData = new ArrayCollection( a as Array );
	    	}else if(a is ArrayCollection){
	    		sharedData = ArrayCollection( a );
	    	}
	    	apply();
	    }
	    
	    private function onCreationComplete(event:FlexEvent):void{
	    	removeEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
	    	apply();
	    }
	    
	    public function get isPopulated():Boolean{
	    	return (sharedData != null)
	    }
	    
	    private function apply():void{
	    	if(sharedData)dataProvider = sharedData;
	    }
	    
		
	}
}